home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / RBBS.SLT < prev    next >
Text File  |  1992-03-20  |  7KB  |  216 lines

  1. //-----------------------------------------------------------
  2. // RBBS.SL? Automatic logging into an RBBS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs, BEFORE you use it. Then recompile with CS RBBS.
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[] = "RBBS"   // This BBS type.      
  18.    ,line    [80]             // General input line.
  19.                              // For the Global storage:
  20.    ,global   []="GLOBAL"     // Global script.
  21.    ,bbstype  []="BTYPE"      // BBS type.
  22. // ,short    []="SHORT"      // Short BBS name.
  23. // ,protocol []="CPROT"      // Current protocol.
  24. // ,conf     []="CONF"       // Current conference
  25. // ,prompt   []="PROMPT"     // Current command prompt.
  26.    ;     
  27.  
  28. int tol = 300                            // No activity for 1 minute
  29.    ,stat, tmark
  30.    ;
  31.  
  32. //-----------------------------------------------------------   
  33. // Script starts here.
  34. //-----------------------------------------------------------   
  35.  
  36. main()
  37. {
  38. int novice;                              // Novice indicator.
  39.  
  40. // Variables for tracking:
  41. int mo,        // More?
  42.     en,        // ENter to continue
  43.     ak,        // Any key to continue
  44.     sc,        // Scan for mail
  45.     cm,        // Main command.
  46.     rb,        // Read Bulletins
  47.     nv;        // Novice.
  48.  
  49. // Only if online.
  50.  
  51.   if (!carrier())  
  52.   { failtone();
  53.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  54.     return (-1);
  55.   }
  56.  
  57.   read (bbstype,line);                   // Get BBS type. 
  58.  
  59.   if (line != thisBBStype)  
  60.   { wrongBBS();                          // Doesn't match script!
  61.     return (-1);
  62.   }
  63.  
  64.   entry();                               // Updates colors & status bar. 
  65.   cputs ("^K^K^K");                      // Send a BREAK to stop that     
  66.                                          // stupid heading.
  67.   novice = 0;                            // Assume I'm an expert.
  68.  
  69. // Start looking for requests from RBBS.
  70.  
  71.   mo = track ("N,C,A>?",0);              // More?
  72.   en = track ("A)bort?",0);              // ENTER to continue
  73.   ak = track ("ontinue",0);              // Any key to continue
  74.   sc = track ("[Y],N)?",0);              // Scan for mail/bulletins
  75.   cm = track ("V,W,X>?",0);              // Main command.
  76.   rb = track (" none)?",0);              // Read Bulletins
  77.   nv = track ("────── ",0);              // If novice.
  78.  
  79.   tmark = timer_start (tol);             // Gimme half a minute.
  80.  
  81.   while ((stat=trig()) > 0)              // answer any questions.
  82.   { if (stat==nv)                        // Novice?
  83.       novice = 1;
  84.  
  85.     else if (stat==en || stat==mo        // ENTER to continue or MORE?
  86.          ||  stat==sc)                   // Scan for mail?
  87.       cputs ("N^M");                     // No thanks. 
  88.  
  89.     else if (stat==ak                    // Any Key to continue
  90.          ||  stat==rb)                   // Read Bulletins?
  91.       cputs ("^M");
  92.  
  93.     else if (stat==cm)                   // Command?
  94.     { if (novice)                        // Novice?
  95.       { novice=0;                        // No I'm not!
  96.         cputs ("X^M");                   // Tell him I'm an expert!
  97.       }
  98.       else  
  99.         break;                           // Done!
  100.     }
  101.   }
  102.   release();                             // Release timer & tracks.
  103.  
  104. // Time-out or carrier lost!
  105.  
  106.   if (stat < 0)
  107.   { failtone();                          // Play fail tone.
  108.     status_wind ("Logon failed!",20);
  109.     return (-1);
  110.   }
  111.  
  112.   cputs ("R S^M");
  113.   return(0);  
  114. }
  115.  
  116. //-----------------------------------------------------------
  117. // Wrong BBS type.
  118. //-----------------------------------------------------------
  119.  
  120. wrongBBS()
  121. {
  122. str help[48];
  123.  
  124.     failtone();                          // Alarm.    
  125.     help = "This script is for ";        // Catenate strings.
  126.     strcat (help,thisBBStype);
  127.     strcat (help," only!");
  128.     status_wind (help,20);               // Display message for 2 sec.
  129. }
  130.  
  131. //-----------------------------------------------------------
  132. // Play fail tone.
  133. //-----------------------------------------------------------
  134.  
  135. failtone()
  136. {
  137.   int n;
  138.   for (n=140; n > 10; n = 100*n/120) 
  139.   { tone(n*10,12);                       // Fail tone!!
  140.     terminal();                          // Process text.
  141.   }
  142. }
  143.  
  144. //-----------------------------------------------------------
  145. // Routine to update colors and status bar.
  146. //-----------------------------------------------------------
  147.  
  148. entry ()
  149. {
  150.   _back_color = 1;
  151.   _fore_color = 14;
  152.   update_term();
  153. }
  154.  
  155. //-----------------------------------------------------------
  156. // Play good tune.
  157. //-----------------------------------------------------------
  158.  
  159. goodtone()
  160. {
  161. int n;
  162.   for (n=20; n < 200; n = 144*n/100) 
  163.   { tone(n*10,6);                        // Good tone!
  164.     terminal();                          // Process text.
  165.   }
  166. }
  167.  
  168. //-----------------------------------------------------------
  169. //  Trig loop. Waits here until either one "trig string" is
  170. //  found, or we have a time-out, or carrier is lost.
  171. //-----------------------------------------------------------
  172.  
  173. trig()
  174. {
  175. int i;
  176.   do
  177.   { terminal();
  178.   }  while (!time_up (tmark)             // Loop until time-out
  179.           && carrier()                   // or carrier lost
  180.           && (i=track_hit(0))==0);       // or we trigged.
  181.   if (i==0) 
  182.     i = -1;                              // Error!
  183.   else
  184.     timer_restart (tmark,tol);           // Restore timer.
  185.   return (i);
  186. }
  187.  
  188. //-----------------------------------------------------------
  189. // Free timer and tracking functions.
  190. //-----------------------------------------------------------
  191.  
  192. release()
  193. {
  194.   timer_free (tmark);                    // free timer channel
  195.   track_free (0);                        // and all track channels.
  196. }
  197.  
  198.  
  199. //-----------------------------------------------------------
  200. // Read a global variable.
  201. //-----------------------------------------------------------
  202.  
  203. read (str name, str varname)
  204. {
  205.   return (call (global,"R",name,varname));
  206. }
  207.  
  208. //-----------------------------------------------------------
  209. // Write a global variable.
  210. //-----------------------------------------------------------
  211.  
  212. write(str name, str varname)
  213.   return (call (global,"W",name,varname));
  214. }
  215.